package com.feng.chat.mapper;

import com.feng.chat.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户笔记表 Mapper 接口
 * </p>
 *
 * @author dyf
 * @since 2022-05-31
 */
public interface ArticleMapper extends BaseMapper<Article> {

    /**
     * 获取该标签的笔记
     * @param tagId
     * @param uid
     * @return
     */
    @Select("SELECT *  FROM article WHERE FIND_IN_SET(#{tagId},tags_id) AND `status` = 1 AND user_id = #{uid}")
    public List<Article> getTagArticle(Integer tagId,Integer uid);

    /**
     * 获取近期笔记
     * @param uid
     * @return
     */
    @Select("SELECT * FROM article WHERE created_at > DATE_SUB(CURDATE(),INTERVAL 3 MONTH) AND `status` = 1 AND user_id = #{uid}")
    public List<Article> getRecentArticle(Integer uid);
}
